<template>
	<div>
		<div class="box">
			<uni-forms
				ref="form"
				:model="currentInfoData"
				validate-trigger="bind"
				:label-position="state == 'write' ? 'top' : 'left'"
				label-width="auto">
				<FromItem
					label="上牌费（台）"
					:required="true"
					:state="
						state == 'readonly'
							? 'readonly'
							: config.quotationProductSchemeRule
									.openRegistrationFeeModification == 1
							? 'write'
							: 'readonly'
					"
					name="carLicensePrice">
					<AInput
						:state="
							state == 'readonly'
								? 'readonly'
								: config.quotationProductSchemeRule
										.openRegistrationFeeModification == 1
								? 'write'
								: 'readonly'
						"
						v-model="currentInfoData.carLicensePrice"
						type="price"
						placeholder="请输入金额"
						@change="change_carLicensePrice"></AInput>
				</FromItem>
				<FromItem
					label="限牌城市牌照费（台）"
					:required="true"
					:state="
						state == 'readonly'
							? 'readonly'
							: config.quotationProductSchemeRule
									.openLicenseFeeModification == 1
							? 'write'
							: 'readonly'
					"
					name="carLicenseCityPrice">
					<AInput
						:state="
							state == 'readonly'
								? 'readonly'
								: config.quotationProductSchemeRule
										.openLicenseFeeModification == 1
								? 'write'
								: 'readonly'
						"
						v-model="currentInfoData.carLicenseCityPrice"
						type="price"
						placeholder="请输入金额"
						@change="change_carLicenseCityPrice"></AInput>
				</FromItem>
				<FromItem
					label="购置税（台）"
					:required="true"
					state="readonly"
					name="carPurchaseTax">
					<AInput
						state="readonly"
						v-model="currentInfoData.carPurchaseTax"
						type="price"
						placeholder="请输入金额"></AInput>
				</FromItem>
			</uni-forms>
		</div>
	</div>
</template>

<script>
	import * as app from '@/api/index.js';
	import * as apis from '@/api/quota/apply/api.js';
	import FromItem from '../formItem/index.vue';
	export default {
		name: '',
		components: { FromItem },
		dicts: [],
		props: {},
		inject: [
			'details_provide',
			'config_provide',
			'deptList_provide',
			'state_provide',
			'index_provide',
		],
		data() {
			return {};
		},
		computed: {
			details() {
				return this.details_provide();
			},
			config() {
				return this.config_provide();
			},
			deptList() {
				return this.deptList_provide();
			},
			state() {
				return this.state_provide();
			},
			index() {
				return this.index_provide();
			},
			currentInfoData() {
				return this.details.productList?.[this.index] ?? {};
			},
			firstInfoData() {
				return this.details.productList?.[0] ?? {};
			},
		},
		watch: {},
		filters: {},
		created() {},
		mounted() {},
		methods: {
			change_carLicensePrice() {
				let row = this.currentInfoData;
				if (this.notEmpty(row.carLicensePrice)) {
					this.currentInfoData.planConf.carLicensePrice_state =
						'changed';
				} else {
					this.currentInfoData.planConf.carLicensePrice_state = '';
				}
			},
			change_carLicenseCityPrice() {
				let row = this.currentInfoData;
				if (this.notEmpty(row.carLicenseCityPrice)) {
					this.currentInfoData.planConf.carLicenseCityPrice_state =
						'changed';
				} else {
					this.currentInfoData.planConf.carLicenseCityPrice_state =
						'';
				}
			},
		},
		beforeDestroy() {
			if (this.notEmpty(this.details?.productList?.[this.index])) {
				this._resetFields([
					{
						data: this.currentInfoData,
					},
				]);
			}
		},
	};
</script>

<style lang="scss" scoped>
	.box {
		// margin: 20rpx;
		padding-top: 20rpx;
		background-color: #fff;
		border-radius: 8rpx;
		.title {
			border-bottom: 1px solid #e9e9e9;
			font-weight: 500;
			padding-bottom: 10rpx;
			margin-bottom: 10rpx;
		}
	}
</style>
